<template>
  <div class="home">
    <!-- 搜索区域卡片 -->
    <div class="search-card">
      <div class="search-container">
        <div class="search-box">
          <input
              type="text"
              placeholder="企业名称/统一信用代码"
              v-model="companyName"
              class="search-input"
              @keyup.enter="handleSearch"
          >
          <button class="search-btn" @click="handleSearch">查询</button>
          <button class="clear-btn" @click="handleClear">清空</button>
        </div>
      </div>
    </div>

    <!-- 企业基本信息卡片 - 始终显示 -->
    <div class="company-card">
      <!-- 加载状态 -->
      <div class="loading-overlay" v-if="loading">
        <div class="loading-spinner"></div>
        <p>正在查询企业信息...</p>
      </div>

      <!-- 企业头部信息 -->
      <div class="company-header">
        <div class="company-main-info">
          <h2 class="company-name">{{ companyInfo.name || '企业名称' }}</h2>
          <div class="company-status" :class="getRegistrationStatusClass(companyInfo.registrationStatus)">
            {{ companyInfo.registrationStatus || '登记状态' }}
          </div>
        </div>
        <div class="company-meta">
          <span class="credit-code">统一社会信用代码: {{ companyInfo.creditCode || '--' }}</span>
          <div class="info-tags">
            <span class="score-tag" v-if="companyInfo.scale">企业规模: {{ companyInfo.scale }}</span>
            <span class="risk-tag" v-if="companyInfo.industry">行业: {{ companyInfo.industry }}</span>
            <span class="risk-tag" v-if="companyInfo.insuredCount">参保人数: {{ companyInfo.insuredCount }}人</span>
            <span class="risk-tag" v-if="companyInfo.isHighTech">高新技术企业: {{ companyInfo.isHighTech }}</span>
          </div>
        </div>
      </div>

      <!-- 企业基本信息详情 -->
      <div class="company-details">
        <div class="detail-section">
          <h3 class="section-title">基本信息</h3>
          <div class="detail-grid">
            <div class="detail-item">
              <span class="detail-label">法定代表人</span>
              <span class="detail-value">{{ companyInfo.legalRepresentative || '--' }}</span>
            </div>
            <div class="detail-item">
              <span class="detail-label">成立日期</span>
              <span class="detail-value">{{ formatDate(companyInfo.establishmentDate) || '--' }}</span>
            </div>
            <div class="detail-item">
              <span class="detail-label">注册资本</span>
              <span class="detail-value">{{ companyInfo.registeredCapital || '--' }}</span>
            </div>
            <div class="detail-item">
              <span class="detail-label">实缴资本</span>
              <span class="detail-value">{{ companyInfo.paidInCapital || '--' }}</span>
            </div>
            <div class="detail-item">
              <span class="detail-label">企业类型</span>
              <span class="detail-value">{{ companyInfo.companyType || '--' }}</span>
            </div>
            <div class="detail-item">
              <span class="detail-label">登记机关</span>
              <span class="detail-value">{{ companyInfo.registrationAuthority || '--' }}</span>
            </div>
            <div class="detail-item">
              <span class="detail-label">注册地址</span>
              <span class="detail-value">{{ companyInfo.registeredAddress || '--' }}</span>
            </div>
            <div class="detail-item">
              <span class="detail-label">营业期限</span>
              <span class="detail-value">
                {{ formatDate(companyInfo.businessTermStartDate) || '--' }}
                <span v-if="companyInfo.businessTermEndDate">- {{ formatDate(companyInfo.businessTermEndDate) || '长期' }}</span>
              </span>
            </div>
            <div class="detail-item">
              <span class="detail-label">联系电话</span>
              <span class="detail-value">{{ companyInfo.phoneNumber || '--' }}</span>
            </div>
            <div class="detail-item">
              <span class="detail-label">电子邮箱</span>
              <span class="detail-value">{{ companyInfo.emailAddress || '--' }}</span>
            </div>
            <div class="detail-item">
              <span class="detail-label">公司网站</span>
              <span class="detail-value">{{ companyInfo.website || '--' }}</span>
            </div>
            <div class="detail-item">
              <span class="detail-label">员工规模</span>
              <span class="detail-value">{{ companyInfo.employmentStability || '--' }}</span>
            </div>
          </div>
        </div>

        <div class="detail-section" v-if="companyInfo.mainProducts">
          <h3 class="section-title">主营业务</h3>
          <div class="main-products">
            {{ companyInfo.mainProducts }}
          </div>
        </div>

        <!-- 网站信息 -->
        <div class="detail-section" v-if="companyInfo.websiteInfo">
          <h3 class="section-title">网站信息</h3>
          <div class="website-info">
            {{ companyInfo.websiteInfo }}
          </div>
        </div>

        <!-- 股东信息 -->
        <div class="detail-section">
          <h3 class="section-title">工商登记股东信息</h3>
          <div class="table-container">
            <table class="detail-table">
              <thead>
              <tr>
                <th>股东名称</th>
                <th>持股比例</th>
                <th>认缴出资额</th>
                <th>实缴出资额</th>
                <th>出资方式</th>
              </tr>
              </thead>
              <tbody>
              <tr v-if="!companyInfo.shareholders || companyInfo.shareholders.length === 0">
                <td colspan="5" class="empty-table-placeholder">暂无数据</td>
              </tr>
              <tr v-for="(shareholder, index) in companyInfo.shareholders" :key="index">
                <td>{{ shareholder.name || '-' }}</td>
                <td>{{ shareholder.holdingRatio || '-' }}</td>
                <td>{{ shareholder.subscribedCapital || '-' }}</td>
                <td>{{ shareholder.paidInCapital || '-' }}</td>
                <td>{{ shareholder.investmentMethod || '-' }}</td>
              </tr>
              </tbody>
            </table>
          </div>
        </div>

        <!-- 主要人员 -->
        <div class="detail-section">
          <h3 class="section-title">工商登记主要人员</h3>
          <div class="table-container">
            <table class="detail-table">
              <thead>
              <tr>
                <th>姓名</th>
                <th>职位</th>
                <th>任职日期</th>
              </tr>
              </thead>
              <tbody>
              <tr v-if="!companyInfo.keyPersonnel || companyInfo.keyPersonnel.length === 0">
                <td colspan="3" class="empty-table-placeholder">暂无数据</td>
              </tr>
              <tr v-for="(person, index) in companyInfo.keyPersonnel" :key="index">
                <td>{{ person.name || '-' }}</td>
                <td>{{ person.position || '-' }}</td>
                <td>{{ formatDate(person.employmentDate) || '-' }}</td>
              </tr>
              </tbody>
            </table>
          </div>
        </div>

        <!-- 变更信息 -->
        <div class="detail-section">
          <h3 class="section-title">变更信息</h3>
          <div class="table-container">
            <table class="detail-table">
              <thead>
              <tr>
                <th>变更日期</th>
                <th>变更项目</th>
                <th>变更前内容</th>
                <th>变更后内容</th>
              </tr>
              </thead>
              <tbody>
              <tr v-if="!companyInfo.changeRecords || companyInfo.changeRecords.length === 0">
                <td colspan="4" class="empty-table-placeholder">暂无数据</td>
              </tr>
              <tr v-for="(change, index) in companyInfo.changeRecords" :key="index">
                <td>{{ formatDate(change.changeDate) || '-' }}</td>
                <td>{{ change.changeItem || '-' }}</td>
                <td class="text-truncate">{{ change.beforeChange || '-' }}</td>
                <td class="text-truncate">{{ change.afterChange || '-' }}</td>
              </tr>
              </tbody>
            </table>
          </div>
        </div>

        <!-- 其他信息 -->
        <div class="detail-section">
          <h3 class="section-title">其他信息</h3>
          <div class="detail-grid">
            <div class="detail-item">
              <span class="detail-label">实际控制人</span>
              <span class="detail-value">{{ companyInfo.actualController || '--' }}</span>
            </div>
            <div class="detail-item">
              <span class="detail-label">注销吊销信息</span>
              <span class="detail-value">{{ companyInfo.cancellationInfo || '无' }}</span>
            </div>
          </div>
        </div>
      </div>
    </div>

    <div class="risk-cards">
      <div class="risk-card">
        <div class="risk-header">
          <h3>资产情况</h3>
          <a href="#" class="view-detail" @click.prevent="showDetail('financial')">查看详情 ></a>
        </div>
        <div class="risk-items">
          <div class="risk-item">
            <div class="risk-label">营业收入</div>
            <div class="risk-value">
              <span>{{ riskInfo.financial.revenueGrowthRate || '--' }}</span>
            </div>
          </div>
          <div class="risk-item">
            <div class="risk-label">资产负债率</div>
            <div class="risk-value">{{ riskInfo.financial.assetLiabilityRatio || '--' }}</div>
          </div>
          <div class="risk-item">
            <div class="risk-label">现金流健康度</div>
            <div class="risk-value">{{ riskInfo.financial.cashFlowHealth || '--' }}</div>
          </div>
        </div>
      </div>

      <div class="risk-card">
        <div class="risk-header">
          <h3>债务情况</h3>
          <a href="#" class="view-detail" @click.prevent="showDetail('judicial')">查看详情 ></a>
        </div>
        <div class="risk-items">
          <div class="risk-item">
            <div class="risk-label">涉诉次数</div>
            <div class="risk-value">{{ riskInfo.judicial.litigationCount || '--' }}</div>
          </div>
          <div class="risk-item">
            <div class="risk-label">失信记录</div>
            <div class="risk-value" :class="riskInfo.judicial.dishonestyRecord && riskInfo.judicial.dishonestyRecord !== '无' ? 'bad' : 'good'">{{ riskInfo.judicial.dishonestyRecord || '--' }}</div>
          </div>
          <div class="risk-item">
            <div class="risk-label">被执行人</div>
            <div class="risk-value" :class="riskInfo.judicial.executedPerson && riskInfo.judicial.executedPerson !== '无' ? 'bad' : 'good'">{{ riskInfo.judicial.executedPerson || '--' }}</div>
          </div>
          <div class="risk-item">
            <div class="risk-label">行政处罚</div>
            <div class="risk-value" :class="riskInfo.judicial.administrativePenalty && riskInfo.judicial.administrativePenalty !== '无' ? 'bad' : 'good'">{{ riskInfo.judicial.administrativePenalty || '--' }}</div>
          </div>
        </div>
      </div>

      <div class="risk-card">
        <div class="risk-header">
          <h3>辅助信息</h3>
          <a href="#" class="view-detail" @click.prevent="showDetail('operational')">查看详情 ></a>
        </div>
        <div class="risk-items">
          <div class="risk-item">
            <div class="risk-label">经营状态</div>
            <div class="risk-value good">{{ riskInfo.operational.businessStatus || '--' }}</div>
          </div>
          <div class="risk-item">
            <div class="risk-label">用工稳定性</div>
            <div class="risk-value good">{{ riskInfo.operational.employmentStability || '--' }}</div>
          </div>
          <div class="risk-item">
            <div class="risk-label">股权变更</div>
            <div class="risk-value">{{ riskInfo.operational.equityChange || '--' }}</div>
          </div>
          <div class="risk-item">
            <div class="risk-label">资质许可</div>
            <div class="risk-value good">{{ riskInfo.operational.qualifications || '--' }}</div>
          </div>
        </div>
      </div>
    </div>

    <!-- 新增：企查查接口调用中心卡片 -->
    <div class="api-center-card">
      <div class="api-center-header">
        <h2 class="api-center-title">企查查接口调用中心</h2>
        <div class="api-search-box">
          <input
              type="text"
              placeholder="搜索接口名称或关键词"
              class="api-search-input"
          >
        </div>
      </div>

      <!-- 接口分类标签 -->
      <div class="api-category-tabs">
        <span 
          class="api-tab" 
          :class="{ active: activeApiCategory === 'all' }"
          @click="setActiveApiCategory('all')"
        >
          全部接口
        </span>
        <span 
          class="api-tab" 
          :class="{ active: activeApiCategory === 'basic' }"
          @click="setActiveApiCategory('basic')"
        >
          企业基本信息
        </span>
        <span 
          class="api-tab" 
          :class="{ active: activeApiCategory === 'finance' }"
          @click="setActiveApiCategory('finance')"
        >
          财务信息
        </span>
        <span 
          class="api-tab" 
          :class="{ active: activeApiCategory === 'judicial' }"
          @click="setActiveApiCategory('judicial')"
        >
          司法信息
        </span>
        <span 
          class="api-tab" 
          :class="{ active: activeApiCategory === 'business' }"
          @click="setActiveApiCategory('business')"
        >
          经营信息
        </span>
        <span 
          class="api-tab" 
          :class="{ active: activeApiCategory === 'public' }"
          @click="setActiveApiCategory('public')"
        >
          舆情信息
        </span>
        <span 
          class="api-tab" 
          :class="{ active: activeApiCategory === 'ip' }"
          @click="setActiveApiCategory('ip')"
        >
          知识产权
        </span>
      </div>

      <!-- 接口列表 -->
      <div class="api-list">
        <!-- 接口项 -->
        <div class="api-item" v-for="api in displayedApiList" :key="api.id">
          <div class="api-info">
            <h3 class="api-name">{{ api.name }}</h3>
            <p class="api-desc">{{ api.desc }}</p>
            <p class="api-id">接口ID: {{ api.id }}</p>
          </div>
          <button class="api-call-btn" @click="handleApiView(api)">查看</button>
        </div>
      </div>

      <div class="load-more-btn-container">
        <button 
          class="load-more-btn" 
          @click="loadMoreApis"
          v-if="hasMoreApis"
        >
          加载更多接口 ▼
        </button>
        <div class="no-more-apis" v-else>
          没有更多接口了
        </div>
      </div>

      <!-- 添加API数据对话框 -->
  <api-data-dialog 
    v-model:visible="dialogVisible"
    :title="dialogTitle"
    :api-url="dialogApiUrl"
    :api-params="dialogApiParams"
  />
    </div>
  </div>
</template>

<script>
import axios from 'axios';
import ApiDataDialog from './ApiDataDialog.vue';
export default {
  name: 'CompanyInfo',
  components: {
    ApiDataDialog
  },
  data() {
    return {
      companyName: '正大天晴药业集团股份有限公司',
      activeTab: 'riskProfile',
      loading: false,
      // 初始化 companyInfo 为一个空对象，确保模板中 . 操作符不会报错
      companyInfo: {},
      riskInfo: {
        financial: {},
        judicial: {},
        operational: {}
      },
      // 添加dialog相关的数据
      dialogVisible: false,
      dialogTitle: '',
      dialogApiUrl: '',
      dialogApiParams: {},
      // 添加API分类相关数据
      activeApiCategory: 'all',
      displayedApiCount: 4,
      apiList: [
        {
          id: '1116',
          name: '企业评分查询',
          desc: '获取企业评分数据',
          url: '/qcc/creditScore/get',
          category: 'basic'
        },
        {
          id: '2003',
          name: '企业基础信息',
          desc: '获取企业基础数据',
          url: '/qcc/customerIdentification/get',
          category: 'basic'
        },
        {
          id: 'QCC_FINANCE_002',
          name: '财务报表查询',
          desc: '获取企业年度财务报表、资产负债表、利润表等数据',
          url: '/qcc/finance/report',
          category: 'finance'
        },
        {
          id: 'QCC_JUDICIAL_003',
          name: '涉诉信息查询',
          desc: '获取企业司法涉诉、案件类型、判决结果等信息',
          url: '/qcc/judicial/lawsuit',
          category: 'judicial'
        },
        {
          id: 'QCC_JUDICIAL_004',
          name: '失信被执行人查询',
          desc: '查询企业是否有失信被执行人记录及相关详情',
          url: '/qcc/judicial/dishonesty',
          category: 'judicial'
        },
        {
          id: 'QCC_PUBLIC_005',
          name: '企业舆情查询',
          desc: '获取企业相关新闻报道、社交媒体评论等舆情信息',
          url: '/qcc/public/opinion',
          category: 'public'
        },
        {
          id: 'QCC_ASSET_006',
          name: '不动产抵押查询',
          desc: '查询企业不动产抵押登记信息、抵押价值等数据',
          url: '/qcc/asset/mortgage',
          category: 'business'
        }
      ]
    };
  },
  methods: {
    async handleSearch() {
      // 验证输入
      if (!this.companyName.trim()) {
        // 可以在这里添加一个 Toast 或 Alert 组件提示用户
        console.log('请输入企业名称或统一信用代码');
        return;
      }
    
      await axios.post(
          '/qcc/customerIdentification/get',
          {searchKey: this.companyName},
      ).then(res => {
        if (res.data.code === 200){
          const data = res.data.data;
        this.companyInfo = {
          // 基本信息
          name: data.Name,
          creditCode: data.CreditCode,
          legalRepresentative: data.OperName,
          establishmentDate: data.StartDate,
          registeredCapital: data.RegistCapi,
          paidInCapital: data.RealCapi,
          companyType: data.EconKind,
          registrationAuthority: data.BelongOrg,
          registeredAddress: data.Address,
          businessTermStartDate: data.TermStart,
          businessTermEndDate: data.TermEnd,
          businessScope: data.Scope,
          registrationStatus: data.Status,
          phoneNumber: data.ContactInfo?.Tel,
          emailAddress: data.ContactInfo?.Email,
          website: data.ContactInfo?.WebSiteList?.[0],
          
          // 股东信息
          shareholders: data.PartnerList?.map(partner => ({
            name: partner.StockName,
            holdingRatio: partner.StockPercent,
            subscribedCapital: `${partner.SubscribedCapital}${partner.SubscribedCapitalUnit}`,
            paidInCapital: '', // 数据中未提供
            investmentMethod: partner.StockType
          })) || [],
          
          // 主要人员
          keyPersonnel: data.EmployeeList?.map(person => ({
            name: person.Name,
            position: person.Job,
            employmentDate: '' // 数据中未提供
          })) || [],
          
          // 变更信息
          changeRecords: data.ChangeList?.slice(0, 5).map(change => ({
            changeDate: change.ChangeDate,
            changeItem: change.ProjectName,
            beforeChange: change.BeforeList?.join('; '),
            afterChange: change.AfterList?.join('; ')
          })) || [],
          
          // 其他信息
          actualController: data.ActualControllerList?.map(ctrl => ctrl.Name).join(', '),
          cancellationInfo: data.RevokeInfo || '无',
          
          // 新增信息
          industry: data.Industry?.SubIndustry,
          taxCredit: data.TaxCreditList?.map(tax => `${tax.Year}年${tax.Level}级`).join(', '),
          insuredCount: data.InsuredCount,
          scale: data.Scale === 'L' ? '大型企业' : data.Scale === 'M' ? '中型企业' : data.Scale === 'S' ? '小型企业' : '微型企业',
          isHighTech: data.TagList?.some(tag => tag.Name.includes('高新技术企业')) ? '是' : '否',
          mainProducts: data.MainProductList?.join('、'),
          websiteInfo: data.ApproveSiteList?.map(site => `${site.Name}: ${site.WebAddress}`).join('; ')
        };
        
        // 更新风险信息
        this.riskInfo = {
          financial: {
            revenueGrowthRate: data.FinancialInformation?.Amount || '--',
            assetLiabilityRatio: '--',
            cashFlowHealth: '--'
          },
          judicial: {
            litigationCount: '--',
            dishonestyRecord: '--',
            executedPerson: '--',
            administrativePenalty: '--'
          },
          operational: {
            businessStatus: data.Status,
            employmentStability: data.PersonScope,
            equityChange: '--',
            qualifications: data.AdminLicenseList?.length > 0 ? '有' : '无'
          }
        };
        }
      }).catch( e => {
        console.error();
      })
    },

    handleClear() {
      this.companyName = '';
      this.resetData();
    },

    // 新增：重置数据的方法
    resetData() {
      this.companyInfo = {};
      this.riskInfo = {
        financial: {},
        judicial: {},
        operational: {}
      };
    },

    showDetail(type) {
      console.log(`查看${this.getDetailTypeName(type)}详情`);
      // 这里可以添加跳转到详情页的逻辑
    },

    getDetailTypeName(type) {
      const typeMap = {
        financial: '财务风险',
        judicial: '司法风险',
        operational: '经营风险'
      };
      return typeMap[type] || type;
    },

    formatDate(dateString) {
      if (!dateString) return '';
      try {
        return new Date(dateString).toLocaleDateString('zh-CN');
      } catch (err) {
        return dateString;
      }
    },

    getRegistrationStatusClass(status) {
      if (!status) return '';
      status = status.toLowerCase();
      if (status.includes('存续') || status.includes('在业')) {
        return 'status-active';
      } else if (status.includes('注销')) {
        return 'status-canceled';
      } else if (status.includes('吊销')) {
        return 'status-revoked';
      } else {
        return 'status-other';
      }
    },
    // 新增：处理API查看按钮点击事件
    handleApiView(apiInfo) {
      this.dialogTitle = apiInfo.name;
      this.dialogApiUrl = apiInfo.url;
      this.dialogApiParams = {
        searchKey: this.companyName
      };
      this.dialogVisible = true;
    },
    // 新增：设置活动API分类
    setActiveApiCategory(category) {
      this.activeApiCategory = category;
      // 重置显示数量
      this.displayedApiCount = 4;
    },
    
    // 新增：加载更多API
    loadMoreApis() {
      this.displayedApiCount += 5; // 每次加载5个更多
    }
  },
  computed: {
    // 使用计算属性来获取过滤后的API列表
    displayedApiList() {
      let filteredList = this.apiList;
      
      // 根据分类过滤
      if (this.activeApiCategory !== 'all') {
        filteredList = this.apiList.filter(api => api.category === this.activeApiCategory);
      }
      
      // 根据显示数量截取
      return filteredList.slice(0, this.displayedApiCount);
    },
    
    // 检查是否还有更多API可以加载
    hasMoreApis() {
      let filteredList = this.apiList;
      
      // 根据分类过滤
      if (this.activeApiCategory !== 'all') {
        filteredList = this.apiList.filter(api => api.category === this.activeApiCategory);
      }
      
      return filteredList.length > this.displayedApiCount;
    }
  }
};
</script>

<style scoped>
/* 搜索卡片样式 */
.search-card {
  margin: 20px;
  padding: 20px;
  background-color: white;
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

/* 搜索区域样式 */
.search-container {
  padding: 10px 0;
}

.search-box {
  display: flex;
  gap: 10px;
}

.search-input {
  flex: 1;
  padding: 12px 15px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
  transition: border-color 0.3s ease;
}

.search-input:focus {
  outline: none;
  border-color: #1890ff;
  box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.1);
}

.search-btn {
  background-color: #1890ff;
  color: white;
  border: none;
  padding: 0 24px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: background-color 0.3s ease;
}

.search-btn:hover {
  background-color: #096dd9;
}

.clear-btn {
  background-color: white;
  color: #666;
  border: 1px solid #ddd;
  padding: 0 20px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.3s ease;
}

.clear-btn:hover {
  background-color: #f5f5f5;
  border-color: #ccc;
}

/* 加载状态样式 */
.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.85);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(24, 144, 255, 0.1);
  border-left-color: #1890ff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 15px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* 企业卡片样式 */
.company-card {
  margin: 20px;
  padding: 25px;
  background-color: white;
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
  position: relative; /* 为 loading-overlay 提供定位上下文 */
}

/* 企业头部信息 */
.company-header {
  margin-bottom: 25px;
  padding-bottom: 20px;
  border-bottom: 1px solid #f0f0f0;
}

.company-main-info {
  display: flex;
  align-items: center;
  margin-bottom: 15px;
}

.company-name {
  font-size: 24px;
  font-weight: 600;
  color: #333;
  margin: 0 20px 0 0;
}

.company-status {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
}

.status-active {
  background-color: #e6f7ef;
  color: #52c41a;
}

.status-canceled {
  background-color: #fff1f0;
  color: #ff4d4f;
}

.status-revoked {
  background-color: #fff1f0;
  color: #ff4d4f;
}

.status-other {
  background-color: #f0f8fb;
  color: #1890ff;
}

.credit-code {
  color: #666;
  font-size: 14px;
  display: block;
  margin-bottom: 10px;
}

.info-tags {
  display: flex;
  gap: 15px;
  color: #666;
  font-size: 14px;
  flex-wrap: wrap;
}

.score-tag {
  color: #52c41a;
}

.risk-tag {
  color: #1890ff;
}

/* 详情区域样式 */
.company-details {
  margin-top: 20px;
}

.detail-section {
  margin-bottom: 30px;
}

.section-title {
  font-size: 16px;
  font-weight: 600;
  color: #333;
  margin-bottom: 15px;
  padding-left: 10px;
  border-left: 3px solid #1890ff;
}

/* 详情网格布局 */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 15px;
}

.detail-item {
  display: flex;
  flex-direction: column;
}

.detail-label {
  font-size: 13px;
  color: #999;
  margin-bottom: 4px;
}

.detail-value {
  font-size: 14px;
  color: #333;
  word-break: break-word;
}

/* 表格样式 */
.table-container {
  overflow-x: auto;
}

.detail-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.detail-table th {
  background-color: #f7f8fa;
  color: #666;
  font-weight: 500;
  padding: 12px 15px;
  text-align: left;
  border-bottom: 1px solid #f0f0f0;
}

.detail-table td {
  padding: 12px 15px;
  border-bottom: 1px solid #f0f0f0;
  color: #333;
}

.detail-table tbody tr:hover {
  background-color: #fafafa;
}

.text-truncate {
  max-width: 250px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.empty-table-placeholder {
  text-align: center;
  padding: 30px;
  color: #999;
  font-style: italic;
}

/* 标签导航样式 */
.main-products, .website-info {
  padding: 10px 15px;
  background-color: #f9f9f9;
  border-radius: 4px;
  color: #333;
  line-height: 1.5;
}

/* 标签导航样式 */
.tabs-nav {
  display: flex;
  padding: 0 20px;
  gap: 20px;
  border-bottom: 1px solid #f0f0f0;
  flex-wrap: wrap;
}

.tab {
  padding: 10px 0;
  font-size: 14px;
  color: #666;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}

.tab.active {
  color: #1890ff;
  border-bottom-color: #1890ff;
  font-weight: 500;
}

.tab:hover {
  color: #1890ff;
}

/* 风险卡片样式 */
.risk-cards {
  display: flex;
  gap: 20px;
  padding: 20px;
  flex-wrap: wrap;
}

.risk-card {
  flex: 1;
  background-color: white;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  padding: 15px;
  min-width: 280px;
}

.risk-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.risk-header h3 {
  margin: 0;
  font-size: 16px;
  color: #333;
}

.view-detail {
  color: #1890ff;
  font-size: 14px;
  text-decoration: none;
}

.view-detail:hover {
  text-decoration: underline;
}

.risk-items {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.risk-item {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.risk-label {
  font-size: 14px;
  color: #666;
}

.risk-value {
  font-size: 14px;
  color: #333;
  display: flex;
  align-items: center;
  gap: 5px;
}

.risk-value.good {
  color: #52c41a;
}

.risk-value.bad {
  color: #ff4d4f;
}

.trend.up {
  color: #52c41a;
}

.trend.down {
  color: #ff4d4f;
}

.progress-bar {
  height: 6px;
  background-color: #f0f0f0;
  border-radius: 3px;
  overflow: hidden;
}

.progress {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s ease;
}

/* 新增：企查查接口调用中心样式 */
.api-center-card {
  margin: 20px;
  padding: 20px;
  background-color: white;
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

.api-center-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.api-center-title {
  font-size: 18px;
  font-weight: 600;
  color: #333;
  margin: 0;
}

.api-search-box {
  position: relative;
}

.api-search-input {
  padding: 8px 12px 8px 30px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
  width: 220px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23999' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001c.03.04.062.078.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1.007 1.007 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0z'/%3E%3C/svg%3E") no-repeat 8px center;
}

.api-category-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.api-tab {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 14px;
  cursor: pointer;
  background-color: #f5f7fa;
  color: #666;
  transition: all 0.3s ease;
}

.api-tab.active {
  background-color: #1890ff;
  color: white;
}

.api-tab:hover {
  background-color: #e6f0ff;
  color: #1890ff;
}

.api-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 15px;
  margin-bottom: 20px;
}

.api-item {
  padding: 15px;
  border: 1px solid #f0f0f0;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.api-info {
  flex: 1;
}

.api-name {
  font-size: 16px;
  font-weight: 500;
  color: #333;
  margin: 0 0 5px 0;
}

.api-desc {
  font-size: 14px;
  color: #666;
  margin: 0 0 8px 0;
  line-height: 1.4;
}

.api-id {
  font-size: 13px;
  color: #999;
  margin: 0;
}

.api-tag {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  align-self: flex-start;
}

.api-tag.basic {
  background-color: #e6f7ef;
  color: #52c41a;
}

.api-tag.advanced {
  background-color: #e6f0ff;
  color: #1890ff;
}

.api-call-btn {
  align-self: flex-end;
  background: none;
  border: none;
  color: #1890ff;
  font-size: 14px;
  cursor: pointer;
  padding: 0;
  margin-top: 5px;
}

.api-call-btn:hover {
  text-decoration: underline;
}

.load-more-btn-container {
  text-align: center;
}

.load-more-btn {
  background: none;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 8px 16px;
  font-size: 14px;
  color: #666;
  cursor: pointer;
  transition: all 0.3s ease;
}

.load-more-btn:hover {
  background-color: #f5f5f5;
  border-color: #ccc;
}

.no-more-apis {
  text-align: center;
  padding: 16px;
  color: #999;
  font-size: 14px;
}

/* 响应式调整 */
@media (max-width: 768px) {
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .risk-cards {
    flex-direction: column;
  }

  .tabs-nav {
    gap: 10px;
  }

  .company-main-info {
    flex-direction: column;
    align-items: flex-start;
  }

  .company-status {
    margin-top: 10px;
  }

  .search-box {
    flex-direction: column;
  }

  .search-btn, .clear-btn {
    width: 100%;
    padding: 12px;
  }

  .api-center-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 15px;
  }

  .api-search-input {
    width: 100%;
  }

  .api-list {
    grid-template-columns: 1fr;
  }
}
</style>